import java.util.*;
import java.text.*;
import java.io.*;
/**
 *  The OrderManagement class contains all the current orders in the Restaurant. 
 * This class is primarily used by the Waitress and Chef. OrderManagement will 
 * allow a Waitress to create new orders and allow the Chef to remove old orders 
 * that have been completed.
 * 
 * @author Bryan Milicia, Chirag Patel, Justin Ouellette
 */

public class OrderManagement extends Menud {
	private static Collection<Order> orders = new LinkedList<Order>();
	public static int orderCount = 1;

	/**
	 * Creates a new Order for the selected table
	 */
	public int CreateNewOrder(int tNum){
		Order n = new Order(tNum, orderCount);
		orders.add(n);
		orderCount++;
		return orderCount-1;
	}
	
	/**
	 * addItemToOrder adds individual items from the Menu to the Table's current Order
	 */
	public String addItemToOrder(int oNum, String iName){
		DecimalFormat df= new DecimalFormat("0.00");
		for(Order n: orders){
			if (n.getoNum() == oNum){
				Item i = new Item("Order", iName, n.addItem(iName));
				n.getItems().add(i);
				return (i.getName()+" $"+df.format(i.getPrice()));
			}
			
			
		}
		return"";
	}
	
	/**
	 * deleteItemFromOrder deletes a particular item from the Table's current Order
	 */
	public void deleteItemFromOrder(){
		
	}
	
	/**
	 * sendOrder marks the Table's current order as complete and sends a message to the
	 * Chef terminal
	 */
	public void sendOrder(){}
	/**
	 * printReceipt calculates the total price of all the Items in an Order and then 
	 * prints a listed view of the Items with their individual prices, as well as their
	 * total group sum
	 */
	public String printReceipt(int tabNum){
		String output="";
		for(Order z: orders){
			if(z.getTabNum() == tabNum){
				for(Item i: z.getItems())
				{
				output+=i.getName()+"\n";
				}
			 
			}
		}
		return output;
	}
	/**
	 * markComplete is used by the Chef to acknowledge that an order has been prepared
	 * and is finished
	 */
	public void markComplete(int tNbr)
	{
		for(Order m: orders)
		{
			if(m.getTabNum()==tNbr)
			{
				orders.remove(m);
			}
		}
	}
	/**
	 * messageWaiter sends an alert from the Chef to the Waiter telling that a table's order
	 * is ready to be served. 
	 * @return Message for waiter
	 */
	
	
	
	
	public boolean messageWaiter(){
		return true;
	}
	/**
	 * messageWaiter sends an alert from the Waiter to the Chef, informing the Chef that 
	 * a new order has been placed
	 * @return Message for Chef
	 */
	public boolean messageChef(){
		return true;
	}
/**	
	public static void main(String[] args)
	{	
		CreateNewOrder(2);
		CreateNewOrder(4);
		addItemToOrder(2, "Soda");
		printReceipt(2);
	}
*/
}